<html>
<head>
    <title>公司银行卡列表</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/static/layui//css/layui.css">
    <script src="/static/layui/layui.all.js"></script>
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/js/dealParam.js"></script>
    <script src="/static/js/CodeConst.js"></script>
    <script src="/static/js/common.js"></script>

</head>
<body class="childrenBody">
<fieldset class="layui-elem-field">
    <legend>公司银行卡列表</legend>
    <div class="layui-field-box">
        <div class="layui-inline">
            <a href="/back/company/bankcard/addpage" class="layui-btn layui-btn-normal" data-type="addUser">公司银行卡列表</a>
        </div>
    </div>
</fieldset>
<div class="layui-form users_list">
            <table cellspacing="0" cellpadding="0" border="0" class="layui-table">
                <thead>
                <tr>
                    <#--<th data-field="0" data-unresize="true">-->
                        <#--<div class="layui-table-cell laytable-cell-1-0 laytable-cell-checkbox">-->
                            <#--<input type="checkbox" name="layTableCheckbox" lay-skin="primary"-->
                                   <#--lay-filter="layTableAllChoose">-->
                            <#--<div class="layui-unselect layui-form-checkbox" lay-skin="primary">-->
                                <#--<i class="layui-icon"></i>-->
                            <#--</div>-->
                        <#--</div>-->
                    <#--</th>-->
                    <!--编号、货币名称、交易场景、手续费、创建时间、操作-->
                    <th data-field="loginName">
                        <div class="layui-table-cell laytable-cell-1-loginName"><span>编号</span></div>
                    </th>
                    <th data-field="nickName">
                        <div class="layui-table-cell laytable-cell-1-nickName"><span>持卡人姓名</span></div>
                    </th>
                    <th data-field="email">
                        <div class="layui-table-cell laytable-cell-1-email"><span>银行卡号</span></div>
                    </th>
                    <th data-field="tel">
                        <div class="layui-table-cell laytable-cell-1-tel"><span>开户银行</span></div>
                    </th>
                    <th data-field="tel">
                        <div class="layui-table-cell laytable-cell-1-tel"><span>是否为默认银行卡</span></div>
                    </th>
                    <th data-field="createDate" data-unresize="true">
                        <div class="layui-table-cell laytable-cell-1-createDate"><span>创建时间</span></div>
                    </th>
                    <th data-field="7">
                        <div class="layui-table-cell laytable-cell-1-7" align="center"><span>操作</span></div>
                    </th>
                </tr>
                </thead>
                <tbody id="companyBankCardListBody"></tbody>
            </table>

</div>
    <script>

        function loadData(baseDto) {

            dealBaseDto(baseDto,function (baseDto) {
                printJson(baseDto);
                var companyBankCardList = baseDto.data;
                var companyBankCardListBody = $("#companyBankCardListBody");
                companyBankCardListBody.empty();
                $.each(companyBankCardList,function (index, bankCard) {
                    var text = " <tr data-index=\"0\" class=\"\">\n" +
//                                        "                    <td data-field=\"0\">\n" +
//                                        "                        <div class=\"layui-table-cell laytable-cell-1-0 laytable-cell-checkbox\">\n" +
//                                        "                            <input type=\"checkbox\" name=\"layTableCheckbox\" lay-skin=\"primary\">\n" +
//                                        "                            <div class=\"layui-unselect layui-form-checkbox\" lay-skin=\"primary\">\n" +
//                                        "                                <i class=\"layui-icon\"></i>\n" +
//                                        "                            </div>\n" +
//                                        "                        </div>\n" +
//                                        "                    </td>\n" +
                            "                    <td data-field=\"loginName\">\n" +
                            "                        <div class=\"layui-table-cell laytable-cell-1-loginName\">"+bankCard.id+"</div>\n" +
                            "                    </td>\n" +
                            "                    <td data-field=\"nickName\">\n" +
                            "                        <div class=\"layui-table-cell laytable-cell-1-nickName\">"+bankCard.holderName+"</div>\n" +
                            "                    </td>\n" +
                            "                    <td data-field=\"email\">\n" +
                            "                        <div class=\"layui-table-cell laytable-cell-1-email\">"+bankCard.bankCardNum+"</div>\n" +
                            "                    </td>\n" +
                            "                    <td data-field=\"tel\">\n" +
                            "                        <div class=\"layui-table-cell laytable-cell-1-tel\">"+bankCard.openBank+"</div>\n" +
                            "                    </td>\n" +
                            "                    <td data-field=\"tel\">\n" +
                            "                        <div class=\"layui-table-cell laytable-cell-1-tel\">"+(bankCard.isDefault==0?'否':'是')+"</div>\n" +
                            "                    </td>\n" +
                            "                    <td data-field=\"createDate\" data-content=\"1511792379000\">\n" +
                            "                        <div class=\"layui-table-cell laytable-cell-1-createDate\">"+bankCard.createTime+"</div>\n" +
                            "                    </td>\n" +
                            "                    <td data-field=\"7\" align=\"center\" data-off=\"true\">\n" +
                            "                        <div class=\"layui-table-cell laytable-cell-1-7\">\n" +
                            "                            <a onclick='setBankCardDefault("+bankCard.id+")' class=\"layui-btn layui-btn-danger layui-btn-xs\" lay-event=\"del\">设为默认银行卡</a>\n" +
                            "                            <a onclick='deleteBankCard("+bankCard.id+")' class=\"layui-btn layui-btn-danger layui-btn-xs\" lay-event=\"del\">删除</a>\n" +
                            "                        </div>\n" +
                            "                    </td>\n" +
                            "                </tr>";

                    companyBankCardListBody.append($(text));
                });
            })

        }

        function deleteBankCard(bankCardId)
        {
            $.get("/back/company/bankcard/del?bankCardId="+bankCardId,function (data) {
                init();
            })
        }

        function setBankCardDefault(bankCardId)
        {
            $.get("/back/company/bankcard/setDefault?bankCardId="+bankCardId,function (data) {
                init();
            })
        }

        function init()
        {
            $.ajax(
                    {
                        url: '/back/company/bankcard/list',
                        type: 'get',
                        success: function (baseDto) {
                            loadData(baseDto);
                        }
                    }
            );
        }
        init();
    </script>
</body>
</html>